package io.xccit.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.xccit.pojo.param.OrderParam;
import io.xccit.pojo.param.ShopCartSelectParam;
import io.xccit.result.AjaxResult;
import io.xccit.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author CH_ywx
 * @date 2023-09-20
 * @description
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单接口")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @PostMapping("/save")
    @ApiOperation("订单生成/保存")
    public AjaxResult save(@RequestBody OrderParam orderParam){
        return orderService.saveOrder(orderParam);
    }

    @ApiOperation("订单列表查询")
    @PostMapping("/list")
    public AjaxResult list(@RequestBody ShopCartSelectParam shopCartSelectParam){
        return orderService.listOrder(shopCartSelectParam.getUserId());
    }
}
